Copy hierarchy

There is a dxl that copy the hierarchy of the objects from a module to another?

Is it even possible?

For example, I have this:

void selectNext(DB calledFrom) {
// Returns if cannot find requirement or requirement module 
if ((null reqmtObj) || (null reqmtModule)) {
return
}
 
// Do wrap around search or return if found nowhere to go
if (!null(next(reqmtObj))) {
reqmtObj = next(reqmtObj)
} elseif (!null (first reqmtModule)) {
reqmtObj = first reqmtModule
} else {
return
}
 
(current ModuleRef__) = reqmtModule
(current ObjectRef__) = reqmtObj
repaintReqmtTextCanvas(reqIDCanvas)
updateDialogBoxFooterInfo()
}

I wanna to see if the object is a child of some other object, If it is a child to create one like him in another module that have the same hierarchy that he have in the original module.

 

 


braolive - Tue Jun 25 09:20:40 EDT 2013

Re: Copy hierarchy
llandale - Tue Jun 25 11:52:50 EDT 2013

DXL manual Chapter "Objects" section "Navigation from an object" shows that oParent = parent(o) gets the parent object, return null with the object is already level 1.  Further down we see commands to find "siblings".

-Louie

Re: Copy hierarchy
braolive - Tue Jun 25 12:20:48 EDT 2013

llandale - Tue Jun 25 11:52:50 EDT 2013

DXL manual Chapter "Objects" section "Navigation from an object" shows that oParent = parent(o) gets the parent object, return null with the object is already level 1.  Further down we see commands to find "siblings".

-Louie

I get that part...the thing is a bit more complex I think.

I did the logic below, my problem is that it isnt working like it should...when I run the script, the object in ValDataModule don't respect the hierarchy from the ModuleRef

 

Object findValDataObjectBinary() {
string idStr
Object newValDataObj
int createObjIndex
 
string reqmtTagStr
 
Object firstObj
Object lastObj
int countObjs
 
int firstIndex
int lastIndex
real middleIndex
int middleIndexInt
bool valObjNotFound
 
firstObj = first valDataModule
lastObj = last valDataModule
 
reqmtTagStr = identifier(reqmtObj)
 
// If validation data module is empty, create the validation data object 
if (null lastObj) {
(current ModuleRef__) = valDataModule
valDataModule = edit(path(reqmtModule) "/" valDataFolderName "/" valModStr name(reqmtModule), false)
newValDataObj = create(valDataModule)
 
// Assign the Requirement tag to the validation data object
newValDataObj."Requirement tag" = reqmtTagStr
 
// Save, return current and return
save (Module valDataModule)
downgrade (Module valDataModule)
 
(current ModuleRef__) = reqmtModule
return newValDataObj
}
 
// Count number of objs in validation dada module
countObjs = 1
while(firstObj != lastObj) {
countObjs++
firstObj = next firstObj 
}
 
// Search for requirement tag
firstIndex = 1
lastIndex = countObjs
middleIndex = (lastIndex + firstIndex)/2
middleIndexInt = intOf(middleIndex)
 
// Tests if first in module
idStr = valDataModule[firstIndex]."Requirement tag" ""
if(idStr == reqmtTagStr) {
return valDataModule[firstIndex]
}
 
// Tests if the data object should precede the first object
if (reqmtTagStr < idStr) {
(current ModuleRef__) = valDataModule
valDataModule = edit(path(reqmtModule) "/" valDataFolderName "/" valModStr name(reqmtModule), false)
 
newValDataObj = create(valDataModule)
 
// Assign the Requirement tag to the validation data object
newValDataObj."Requirement tag" = reqmtTagStr
 
// Save, return current and return
save (Module valDataModule)
downgrade (Module valDataModule)
 
(current ModuleRef__) = reqmtModule
return newValDataObj
}
 
// Tests if last in module
idStr = valDataModule[lastIndex]."Requirement tag" ""
if(idStr == reqmtTagStr) {
return valDataModule[lastIndex]
}
 
// Tests if the data object should follow the last object
if (reqmtTagStr > idStr) {
(current ModuleRef__) = valDataModule
valDataModule = edit(path(reqmtModule) "/" valDataFolderName "/" valModStr name(reqmtModule), false)
 
newValDataObj = create(after(valDataModule[lastIndex]))
 
// Assign the Requirement tag to the validation data object
newValDataObj."Requirement tag" = reqmtTagStr
 
// Save, return current and return
save (Module valDataModule)
downgrade (Module valDataModule)
 
(current ModuleRef__) = reqmtModule
return newValDataObj
}
 
 
valObjNotFound = false
while(!valObjNotFound) {
// Tests if lies in the middle of the range
idStr = valDataModule[middleIndexInt]."Requirement tag" ""
if(idStr == reqmtTagStr) {
return valDataModule[middleIndexInt]
 
} elseif (idStr < reqmtTagStr) {
// No more room where to search, end search
if (middleIndexInt == lastIndex-1) {
valObjNotFound = true
createObjIndex = middleIndexInt
}
 
// Search next in the upper part of the range
firstIndex = middleIndexInt
lastIndex = lastIndex
middleIndex = (lastIndex + firstIndex)/2
middleIndexInt = intOf(middleIndex)
 
} elseif (idStr > reqmtTagStr) {
// No more room where to search, end search
if (middleIndexInt == firstIndex+1) {
valObjNotFound = true
createObjIndex = firstIndex
}
 
// Search next in the lower part of the range
firstIndex = firstIndex
lastIndex = middleIndexInt
middleIndex = (lastIndex + firstIndex)/2
middleIndexInt = intOf(middleIndex)
}
}
 
// If object in validation data module is not found
// then creates one
(current ModuleRef__) = valDataModule
valDataModule = edit(path(reqmtModule) "/" valDataFolderName "/" valModStr name(reqmtModule), false)
 
// Creates the validation data object after the object searched
newValDataObj = create(after(valDataModule[createObjIndex]))
 
// Assign the Requirement tag to the validation data object
newValDataObj."Requirement tag" = reqmtTagStr 
 
// Save, return current and return
save (Module valDataModule)
downgrade (Module valDataModule)
 
(current ModuleRef__) = reqmtModule
return newValDataObj
}